package com.njworkorder.Service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njworkorder.Entity.Route;
import com.njworkorder.Service.RouteService;
import com.njworkorder.Mapper.RouteMapper;
import com.njworkorder.Utils.NoCode;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author iron
* @description 针对表【route】的数据库操作Service实现
* @createDate 2024-12-17 14:23:23
*/
@Service
public class RouteServiceImpl extends ServiceImpl<RouteMapper, Route>
    implements RouteService{


    @Override
    public String getUpToDateRouteNo() {
        LambdaQueryWrapper<Route> queryWrapper = new LambdaQueryWrapper<Route>()
                .apply("1=1")
                .orderByDesc(Route::getRouteNo).last("limit 1");
        List<Route> list = list(queryWrapper);
        String routeNo = "000001";
        if (!list.isEmpty()) {
            String s = list.getFirst().getRouteNo().substring(6);
            routeNo = NoCode.getNoCode(s);
        }
        return routeNo;
    }
}




